<!DOCTYPE html>
<html>


<!-- Mirrored from www.gzsxt.cn/theme/hplus/table_basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:01 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>绿地中央广场综合物业办公系统 - 基础表格</title>
    <meta name="keywords" content="绿地中央广场综合物业办公系统">
    <meta name="description" content="绿地中央广场综合物业办公系统">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/select/bootstrap-select.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/customer.css" />
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>档案管理<small>>修改档案</small></h5>
                </div>
                <div class="ibox-content">
                    <form id="updateForm" class="form-horizontal">
                        <input type="hidden" id="eid" name="eid" />
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-3 show-text">
                                    <input type="text" name="ename" id="ename" value="" class="form-control input-sm"/>
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">用户名</label>
                                <div class="col-sm-3 show-text">
                                    <input type="text" name="username" id="username" value="" class="form-control input-sm"/>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">年龄</label>
                                <div class="col-sm-3 show-text">
                                    <input type="text" name="eage" id="eage" value="" class="form-control input-sm"/>
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">性别</label>
                                <div class="col-sm-3 show-text" class="selectpicker form-control">
                                    <select name="esex" class="form-control">
                                        <option value="男">男</option>
                                        <option value="女">女</option>
                                    </select>
                                </div>

                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">身份证号码</label>
                                <div class="col-sm-3 show-text">
                                    <input type="text" name="pnum" id="pnum" value="" class="form-control input-sm"/>
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">联系电话</label>
                                <div class="col-sm-3 show-text">
                                    <input type="text" name="telephone" id="telephone" value="" class="form-control input-sm"/>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">部门</label>
                                <div class="col-sm-3 show-text">
                                    <select name="dfk" class="form-control">
                                        <!-- <option value=""></option> -->
                                    </select>
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">入职时间</label>
                                <div class="col-sm-3 show-text">
                                    <input name="hiredate" id="start" value="" class="laydate-icon form-control layer-date"/>
                                </div>
                            </div>
                        </div>



                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">赋角色</label>
                                <div class="col-sm-9 tips">
                                    <select name="roleid" class="form-control">
                                        <!-- <option value=""></option> -->
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-9 show-text">
                                    <textarea name="remark" class="form-control">

                                    </textarea>
                                </div>

                            </div>
                        </div>

                        <div class="row">
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="row">
                            <div class="form-group">
                                <div class="col-sm-3 col-sm-offset-3 text-right">
                                    <button type="button" id="updateBtn" class="btn btn-primary"><i class="fa fa-save"></i> 保存内容</button>
                                </div>
                                <div class="col-sm-3">
                                    <a href="list-employee.html" class="btn btn-white"><i class="fa fa-reply"></i> 返回</a>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>




<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="js/plugins/select/bootstrap-select.min.js"></script>
<script src="js/plugins/layer/laydate/laydate.js"></script>
<script src="js/jquery.serializejson.min.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

    $(function(){

        //初始化日期控件
        laydate({elem: "#start"});

        var str = window.location.search
        var id = str.substring(str.lastIndexOf("id")+"id".length+1)
        $("#eid").val(id)

        $.ajax({
            url:"dept/all",
            type:"get",
            dataType:"json",
            async:false,
            success:function(ret){
                if(ret.status){
                    $.each(ret.data.items,function(i,dept){
                        $("select[name='dfk']").append('<option value="'+dept.deptno+'">'+dept.dname+'</option>')
                    })
                }
            }
        })

        $.ajax({
            url:"role/all",
            type:"get",
            dataType:"json",
            async:false,
            success:function(ret){
                if(ret.status){
                    $.each(ret.data.items,function(i,role){
                        $("select[name='roleid']").append('<option value="'+role.roleid+'">'+role.rolename+'</option>')
                    })
                }
            }
        })

        $.ajax({
            url:"emp/"+id,
            type:"get",
            dataType:"json",
            async:false,
            success:function(ret){
                if(ret.status){
                    $("input[name='ename']").val(ret.data.item.ename)
                    $("input[name='username']").val(ret.data.item.username)
                    $("input[name='eage']").val(ret.data.item.eage)
                    $("option[value='"+ret.data.item.esex+"']").attr("selected","selected")
                    $("input[name='pnum']").val(ret.data.item.pnum)
                    $("input[name='telephone']").val(ret.data.item.telephone)
                    $("option[value='"+ret.data.item.dfk+"']").attr("selected","selected")
                    $("input[name='hiredate']").val(ret.data.item.hiredate)
                    $("option[value='"+ret.data.item.role.roleid+"']").attr("selected","selected")
                    $("textarea[name='remark']").text(ret.data.item.remark)
                }

            }
        })

        $("#updateBtn").click(function(){

            var data = $("#updateForm").serializeJSON()
            var roleid = $("select[name='roleid']").val()

            $.ajax({
                url:"emp/update/"+roleid,
                type:"post",
                data:JSON.stringify(data),
                dataType:"json",
                contentType:"application/json",
                success:function(ret){
                    if(ret.status){
                        window.location.href="list-employee.html"
                    }
                }
            })

        })
    })

</script>

</body>


</html>

